//package org.itboys.product.service;
//
//import com.google.common.collect.Lists;
//import com.google.common.collect.Maps;
//import org.apache.commons.lang3.StringUtils;
//import org.itboys.admin.cache.SysDictionaryLoader;
//import org.itboys.admin.service.SysDictionaryService;
//import org.itboys.commons.CommonConstants;
//import org.itboys.framework.resource.ResourceHolder;
//import org.itboys.mongodb.core.MongoDataSource;
//import org.itboys.mongodb.service.BaseService;
//import org.itboys.mongodb.utils.page.Page;
//import org.itboys.pay.alipay.AlipayWapResult;
//import org.itboys.pay.constant.PayConstants;
//import org.itboys.pay.weixin.Unifiedorder;
//import org.itboys.pay.weixin.WXPayService;
//import org.itboys.pay.weixin.WeixinPaySignTool;
//import org.itboys.pay.weixin.WeixinPayUtils;
//import org.itboys.product.cache.OrderLoader;
//import org.itboys.product.constant.ProductConstant;
//import org.itboys.product.entity.Order;
//import org.itboys.product.entity.Product;
//import org.itboys.redis.RedisCacheClient;
//import org.itboys.weixin.entity.WeixinConfig;
//import org.itboys.weixin.entity.WeixinSendInfo;
//import org.itboys.weixin.service.WeixinConfigService;
//import org.itboys.weixin.service.WeixinSendInfoService;
//import org.itboys.weixin.tools.WeixinSendUtils;
//import org.mongodb.morphia.query.Query;
//import org.slf4j.Logger;
//import org.slf4j.LoggerFactory;
//import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.stereotype.Service;
//import org.springframework.transaction.annotation.Transactional;
//
//import javax.annotation.Resource;
//import javax.servlet.http.HttpServletRequest;
//import java.math.BigDecimal;
//import java.util.Date;
//import java.util.List;
//import java.util.Map;
//
//@Service
//public class OrderService extends BaseService<Order, Long> {
//    private static final long serialVersionUID = 4495340193729890410L;
//
//    protected Logger logger = LoggerFactory.getLogger(getClass());
//
//    @Resource(name="productDS")
//    private MongoDataSource orderDS;
//    @Resource(name="orderLoader")
//    private OrderLoader orderLoader;
//    @Resource(name="sysDictionaryLoader")
//    private SysDictionaryLoader sysDictionaryLoader;
//
//    @Autowired
//    private ProductService productService;
//    @Autowired
//    private WeixinConfigService weixinConfigService;
//    @Autowired
//    private ResourceHolder resourceHolder;
//    @Autowired
//    private SysDictionaryService sysDictionaryService;
//    @Autowired
//    private WeixinSendInfoService sendInfoService;
//    @Autowired
//    private RedisCacheClient redisCacheClient;
//
//    @Override
//    protected MongoDataSource getMongoDataSource() {
//        return orderDS;
//    }
//
//    @Override
//    protected Class<Order> getEntityClass() {
//        return Order.class;
//    }
//
//    public Order createOrder(Long memberId, Long productId, Integer num,
//                            Integer payMethod, String address, String name, String mobile, String postcode){
//        Order order = new Order();
//        order.setStatus(ProductConstant.OrderStatic.ORDER_STATUS_CREATE);
//        order.setMemberId(memberId);
//        order.setProductId(productId);
//        order.setNum(num);
//        order.setPayMethod(payMethod);
//        order.setCreateTime(new Date());
//        order.setUpdateTime(new Date());
//        Product product = productService.getById(productId);
//        order.setSellerId(product.getSellerId());
//        order.setProductName(product.getName());
//        order.setProductImage(product.getImage());
//        if(product.getProductStore() == null || product.getProductStore() == 0){
//            return null;
//        }
//        product.setProductStore(product.getProductStore() - num);
//        productService.update(product);
//        if(payMethod.equals(ProductConstant.OrderStatic.PAY_BEAN)){
//            order.setTotalFee(product.getPowerBean() * 100 * num);
//        } else {
//            order.setTotalFee(product.getPrice() * num);
//        }
//        order.setMobile(mobile);
//        order.setName(name);
//        order.setAddress(address);
//        order.setPostcode(postcode);
//        super.save(order);
//        orderLoader.get(order.getOrderNo());//加入redis缓存
//        return order;
//    }
//
//}
